// 2014-02-01 Tyrghen
//---------------------------------------------
// Usage:
//  ["other_marker"] call edt_fnc_boxMarker;
//  [trigger_enemies] call edt_fnc_boxMarker;
//  [unit_vip] call edt_fnc_boxMarker;
//  [12453,26599,213] call edt_fnc_boxMarker;
//---------------------------------------------
// Purpose:
// 
// 
// Parameters:
// - 
//
// Returns:
// 
//---------------------------------------------
// Objectif:
// 
//
// Paramètres:
// - 
//
// Renvoie:
// 
//---------------------------------------------

//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "editor\fn_boxMarker.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

if (!isServer) exitWith {TRACE("Not Server")};

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_m_name","_m_pos","_m_shape","_m_col","_m_size","_m_text","_m_dir","_m_type","_m_brush","_m_alpha","_count","_done","_shape"];

_count = 0;
_done = false;

while { ((markerShape (format["box_%1",_count])) != "") } do {
	INC(_count);
};
_m_name = format["box_%1",_count];

_m_shape = "ICON";
_m_col = "Default";
_m_size = [];
_m_text = "";
_m_dir = 0;
_m_type = "Empty";
_m_brush = "Solid";
_m_alpha = -888888;

DEFAULT_PARAM(_m_pos,0,ARR_3(0,0,0));

if (IS_STRING(_m_pos)) then {
	if (IS_MARKER(_m_pos)) then {
		_m_shape = markerShape _m_pos;
		_m_col = markerColor _m_pos;
		_m_size = markerSize _m_pos;
		_m_text = markerText _m_pos;
		_m_dir = markerDir _m_pos;
		_m_type = markerType _m_pos;
		_m_brush = markerBrush _m_pos;
		_m_alpha = markerAlpha _m_pos;
		_m_pos = markerPos _m_pos;
		_done = true;
	};
};	
if (!_done) then {
	if (IS_ARRAY(_m_pos) && { count _m_pos == 3}) then {
		_done = true;
	} else {
		_shape = [_m_pos] call FFUNC(toShape);
		_m_pos = _shape select 0;
		_done = true;
	};
};

DEFAULT_PARAM(_m_shape,1,_m_shape);
DEFAULT_PARAM(_m_col,2,_m_col);
DEFAULT_PARAM(_m_size,3,_m_size);
DEFAULT_PARAM(_m_text,4,_m_text);
DEFAULT_PARAM(_m_dir,5,_m_dir);
DEFAULT_PARAM(_m_type,6,_m_type);
DEFAULT_PARAM(_m_brush,7,_m_brush);
DEFAULT_PARAM(_m_alpha,8,_m_alpha);

if (!IS_ARRAY(_m_pos)) exitWith {ERROR("Position is not an array")};
if (_m_shape == "" ) then { _m_shape = "ICON" };
if (_m_col == "" ) then { _m_col = "Default" };
if (count _m_size <= 0) then { _m_size = [1,1] };
if (_m_type == "" ) then { _m_type = "Empty" };
if (_m_brush == "" ) then { _m_brush = "Solid" };

_params = [_m_name,_m_pos,_m_shape,_m_col,_m_size,_m_text,_m_dir,_m_type,_m_brush,_m_alpha];

[QGVAR(all_marker),[_params,TMF_SERVER_INSTANCE_ID,false],THIS_FILE] call FFUNC(callEvent);

TRACE("End");
TMFPROFILERSTOP;
_m_name;